package org.example.design.facade.test1;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;

/**
 * @author huangshen
 * @version 0
 * @description PageMaker
 * @since 2022/2/10 16:13
 */

public class PageMaker {



    private PageMaker(){}

    public static void makeWelComePage(String mailAddr, String fileName) throws Exception{

        try(
            FileWriter fileWriter = new FileWriter(fileName)
        ){

            Map<String, String> value = new DataBase().getValue();
            String userName = value.get("gugu@qq.com");
            HtmlWriter writer = new HtmlWriter(fileWriter);
            writer.title("Welcome to" + userName + "'s page");
            writer.paragraph("欢迎来到" + userName + "的主页");
            writer.paragraph("等着你的邮件哦。");
            writer.mailto(mailAddr, userName);
            writer.close();

            System.out.println(fileName + "is created for " + mailAddr + "(" + userName + ")");

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
